package com.qqtech.qquan.community.service;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.qqtech.core.common.enums.YesNoEnum;
import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.community.dao.CommunityNoticeDao;
import com.qqtech.qquan.community.enums.CommunityNoticeStatusDictEnum;
import com.qqtech.qquan.community.model.CommunityNotice;
import com.qqtech.qquan.community.model.CommunityNoticeVo;

@Service
public class CommunityNoticeServiceImpl extends BaseServiceImpl<CommunityNotice> implements CommunityNoticeService {
	public static final Logger log = LoggerFactory.getLogger(CommunityNoticeServiceImpl.class);

	@Resource
	private CommunityNoticeDao communityNoticeDao;

	@Override
	protected BaseDao<CommunityNotice> getBaseDao() {
		return communityNoticeDao;
	}

	@Override
	public int increasePv(Integer id) {
		return communityNoticeDao.updatePv(id);
	}

	@Override
	public CommunityNoticeVo handleDetail(Integer id) {
		communityNoticeDao.updatePv(id);
		CommunityNoticeVo communityNewsVo = communityNoticeDao.getById(id);
		return communityNewsVo;
	}

	@Override
	public int hide(Integer id) {
		CommunityNotice communityNews = new CommunityNotice();
		communityNews.setId(id);
		communityNews.setStatus(CommunityNoticeStatusDictEnum.DELETE.getCode());
		communityNews.setIsShow(YesNoEnum.NO.getCode());
		return communityNoticeDao.updateById(communityNews);
	}

	@Override
	public int show(Integer id) {
		CommunityNotice communityNews = new CommunityNotice();
		communityNews.setId(id);
		communityNews.setStatus(CommunityNoticeStatusDictEnum.NORMAL.getCode());
		communityNews.setIsShow(YesNoEnum.YES.getCode());
		return communityNoticeDao.updateById(communityNews);
	}
}